import 'package:flutter_screenutil/screenutil.dart';
import 'package:flutter/material.dart';

import 'package:heyangkuaidai/DemonStrateModule/Components/InputWidget.dart';
import 'package:heyangkuaidai/DemonStrateModule/Components/SmsCodeItem.dart';
import 'package:heyangkuaidai/DemonStrateModule/Components/NavigationBar.dart';
import 'package:heyangkuaidai/DemonStrateModule/LoanLimitFindPage.dart';
class LoanSubscribePage extends StatefulWidget {
  @override
  _FirstPageState createState() => _FirstPageState();
}

class _FirstPageState extends State<LoanSubscribePage> {
 String idNum;
 String name;
 String phone;
 String smscode;
 String num;
 @override
 void initState() {
    // TODO: implement initState
    super.initState();
    idNum ='';
    name ='';
    phone ='';
    smscode ='';
    num ='';
  }
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 375, height: 667, allowFontScaling: true);
    return Scaffold(
        resizeToAvoidBottomInset: false,
        body:Column(
          children: [
            SizedBox(height: MediaQuery.of(context).padding.top,),
            NavigationBar(false,title: "预约信息",),
            Container(height: ScreenUtil().setWidth(0.5),width: ScreenUtil.screenWidth,color: Color(0xffD8D8D8),),
            Container(
              width: ScreenUtil.screenWidth,
              height: ScreenUtil().setWidth(270),
              child: ListView(
                padding: EdgeInsets.only(top: 0),
                children: [
                  scanItem(finishCallback: (text){
                     idNum =text;
                  },maxLenth: 18,),
                  nameItem(title: "真实姓名",hitText:"请输入您的真实姓名",finishCallback: (text){
                     name =text;
                  },maxLenth: 20,),
                  nameItem(title: "手机号",hitText:"请输入手机号方便客户经理与您联系",width: 270,finishCallback: (text){
                      phone =text;
                  },maxLenth: 11,),
                  smsCodeItem(finishCallback: (text){
                      smscode =text;
                  },),
                  nameItem(title: "推荐人工号",hitText: "请输入推荐人工号(选填）",finishCallback: (text){
                      num =text;
                  },maxLenth: 20),
                ],
              )
            ) ,
           InkWell(
             onTap: (){
               print(idNum);
               print(name);
               print(phone);
               print(smscode);
               print(num);
                if(idNum.isEmpty||name.isEmpty||phone.isEmpty||smscode.isEmpty||num.isEmpty){
                  return;
                }
                 Navigator.push(
                  context,
                  new MaterialPageRoute(
                    builder: (context) => new LoanLimitFindPage(),
                  ),
                );
             },
             child: Container(
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(4),
                  color:Color(0xff41A5EE),
                ),
              width: ScreenUtil().setWidth(347),
              height: ScreenUtil().setWidth(44),
              child:Center(
                  child: Text("预约",style: TextStyle(fontSize: ScreenUtil().setSp(17),color: Colors.white),textAlign: TextAlign.center,),
                )
            ) ,
          )

          ],
        )

    );

  }
}
//第一类item
class scanItem extends StatefulWidget {
  final Function finishCallback;
  int maxLenth;
  scanItem({this.finishCallback,this.maxLenth});
  @override
  _scanItemState createState() => _scanItemState();
}

class _scanItemState extends State<scanItem> {

  @override
  Widget build(BuildContext context) {
    return Container(
      color:Colors.white,
      width: ScreenUtil.screenWidth,
      height: ScreenUtil().setWidth(50),
      child:Column(
        children: [
          Container(height: ScreenUtil().setWidth(49),
          child:Row(
            children: [
              SizedBox(width:ScreenUtil().setWidth(14) ,),
              Container(
                width: ScreenUtil().setWidth(80),
                child:Text("身份证号",style: TextStyle(fontSize: ScreenUtil().setSp(15),color:Color(0xff666666)),textAlign: TextAlign.left,),
              ),
              SizedBox(width:ScreenUtil().setWidth(10) ,),
              InputWidget("请输入或扫描身份证",finishCallback: widget.finishCallback,maxlength: widget.maxLenth,),
              SizedBox(
                width: ScreenUtil().setWidth(30),
              ),
              Container(
                child: Image.asset("sources/yy/scan.png"),
                width: ScreenUtil().setWidth(30),
                height: ScreenUtil().setWidth(24.4),
              ),
            ],
          ),),
          Container(height: ScreenUtil().setWidth(0.5),width: ScreenUtil.screenWidth,color: Color(0xffCCCCCC),),
        ],
      )
    );
  }
}
//第二类item
class nameItem extends StatefulWidget {
  String title;
  String hitText;
  double width;
  final Function finishCallback;
  int maxLenth;
  nameItem({this.finishCallback,this.title,this.width,this.hitText,this.maxLenth,Key key}) : super(key: key);
  @override
  _nameItemState createState() => _nameItemState();
}

class _nameItemState extends State<nameItem> {

  @override
  Widget build(BuildContext context) {
    return Container(
        color:Colors.white,
        width: ScreenUtil.screenWidth,
        height: ScreenUtil().setWidth(50),
        child:Column(
          children: [
            Container(height: ScreenUtil().setWidth(49),
              child:Row(
                children: [
                  SizedBox(width:ScreenUtil().setWidth(14) ,),
                  Container(
                    width: ScreenUtil().setWidth(80),
                    child:Text(widget.title,style: TextStyle(fontSize: ScreenUtil().setSp(15),color:Color(0xff666666)),textAlign: TextAlign.left,),
                  ),
                  SizedBox(width:ScreenUtil().setWidth(10) ,),
                  InputWidget(widget.hitText,width: widget.width,finishCallback: widget.finishCallback,maxlength: widget.maxLenth),

                ],
              ),),
            Container(height: ScreenUtil().setWidth(0.5),width: ScreenUtil.screenWidth,color: Color(0xffCCCCCC),),
          ],
        )
    );
  }
}
